/**   
* @Title: DaiHouYwController.java 
* @Package com.zjdiepu.www.manage.api.zpp.controller 
* 
* @author zhangpp
* @date 2017年6月1日 上午11:30:38 
* @version V1.0   
*/
package com.zjdiepu.www.manage.api.zpp.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import springfox.documentation.annotations.ApiIgnore;

import com.zjdiepu.www.base.BaseController;
import com.zjdiepu.www.base.annotation.Add;
import com.zjdiepu.www.base.core.AbstractSysUser;
import com.zjdiepu.www.base.core.ApiResponse;
import com.zjdiepu.www.base.enums.type.DataDicType;
import com.zjdiepu.www.dao.zpp.PublicDao;
import com.zjdiepu.www.ibiz.cache.ICachedDictionaryService;
import com.zjdiepu.www.ibiz.cw.ICwIncomeExpensesItemService;
import com.zjdiepu.www.ibiz.yw.IYwBusinessService;
import com.zjdiepu.www.ibiz.zpp.CaiWuXiangGuanService;
import com.zjdiepu.www.ibiz.zpp.DaiHouYwService;
import com.zjdiepu.www.model.dh.dto.DhRemindLoanSub;
import com.zjdiepu.www.model.yw.dto.YwBusiness;
import com.zjdiepu.www.model.zpp.cwxg.vo.RefundInformationVo;
import com.zjdiepu.www.model.zpp.dhyw.ext.DepositMoneyExt;
import com.zjdiepu.www.model.zpp.pub.ext.ParamsExt;
import com.zjdiepu.www.model.zpp.pub.ext.WhereSqlExt;

/**      
 * 项目名称：diepu-parent-manage   
 * 类名称：DaiHouYwController   
 * 类描述：   
 * 创建人：zhangpp
 * 创建时间：2017年6月1日 上午11:30:38   
 * 修改人：zhangpp
 * 修改时间：2017年6月1日 上午11:30:38   
 * 修改备注：   
 * @version V1.0     
 */
@RestController
@RequestMapping(value= "DaiHouYwController", produces="application/json;charset=UTF-8")
@Api(tags = {"作者：张鹏鹏，电话：15158822934"}, produces="application/json;charset=UTF-8")
public class DaiHouYwController extends BaseController
{
	@Resource
	private CaiWuXiangGuanService caiWuXiangGuanService;
	
	@Resource
	private DaiHouYwService daiHouYwService;
	
	@Resource
	private ICachedDictionaryService iCachedDictionaryService; 
	
	@Resource
	private IYwBusinessService iYwBusinessService;
	
	@Resource
	private ICwIncomeExpensesItemService iCwIncomeExpensesItemService;
	
	@Resource
	private PublicDao publicDao;
	
	/**
	*  放款提醒  还款提醒
	*  @author  zhangpp
	*  @Title:  diepuFangKuanHuanKuan  
	*    
	*  @param  @param dhRemindLoanSub
	*  @param  @return        设定文件  
	*  @return  ApiResponse        返回类型  
	*  @version  V1.0
	*  @throws
	 */
	@RequestMapping(value = "diepuFangKuanHuanKuan", method = RequestMethod.POST)
    public ApiResponse diepuFangKuanHuanKuan(DhRemindLoanSub dhRemindLoanSub) {
		AbstractSysUser currentUser = getCurrentUser();
		daiHouYwService.diepuFangKuanHuanKuan(currentUser,dhRemindLoanSub);
		return ApiResponse.success(true);
    }
	
	/**
	* 贷后业务/客户申请退押金 
	* @author zhangpp
	* @Title: daiHouYwKeHuTuiKuan 
	* 
	* @param @param depositMoneyExt
	* @param @return    设定文件 
	* @return ApiResponse    返回类型 
	* @version V1.0
	* @throws
	 */
	@ApiOperation(value = "贷后业务/客户申请退押金 ", response = Boolean.class, httpMethod="POST", tags={"贷后业务/客户申请退押金"})
    @RequestMapping(value = "daiHouYwKeHuTuiKuan", method = RequestMethod.POST)
    public ApiResponse daiHouYwKeHuTuiKuan(@Validated(Add.class) @ModelAttribute DepositMoneyExt depositMoneyExt) {
		AbstractSysUser currentUser = getCurrentUser();
		daiHouYwService.diepuDaiHouYwKeHuTuiKuan(depositMoneyExt, currentUser);
		return ApiResponse.success(true);
    }
	
	/**
	* 贷后业务 客户申请退押金表
	* @author zhangpp
	* @Title: daiHouYwKeHuShenQingTuiYaJinZhiXing 
	* 
	* @param @param paramsExt
	* @param @return    设定文件 
	* @return Map<String,Object>    返回类型 
	* @version V1.0
	* @throws
	 */
	@RequestMapping(value="daiHouYwKeHuShenQingTuiYaJinZhiXing",method = RequestMethod.POST, produces="application/json;charset=UTF-8")
	public Map<String, Object> daiHouYwKeHuShenQingTuiYaJinZhiXing(@ApiIgnore ParamsExt paramsExt)
	{
		Map<String, Object> maps = success();
		
		RefundInformationVo result =  caiWuXiangGuanService.getRefundInformationEntity(paramsExt);
		maps.put("result", result);
		
		//结算方式
		Map<String, String> settlement_type = iCachedDictionaryService.getValueNamesWithSpaceOption(DataDicType.SETTLEMENT_TYPE,"请选择...");
		maps.put("settlement_type", settlement_type);
		
		return maps;
	}
	
	@ApiOperation(value = "贷后业务/客户申请退押金 ", response = Boolean.class, httpMethod="POST", tags={"贷后业务/客户申请退押金"})
    @RequestMapping(value = "getKeHuTuiYaJinList", method = RequestMethod.POST)
    public Map<String, Object> getKeHuTuiYaJinList(ParamsExt paramsExt) {
		
		Map<String, Object> maps = success();
		
		String busiId = paramsExt.getBusiId();
		
		if(null == busiId || ("").equals(busiId))
		{
			return maps;
		}
		
		//业务表数据
		YwBusiness ywBusiness = iYwBusinessService.selectById(busiId);
		maps.put("ywBusiness", ywBusiness);
		
		//收支管理
		WhereSqlExt whereSqlExt = new WhereSqlExt();
		String whereSql = "select t.id,t.item_code,t.amount_item from cw_income_expenses_item t where t.busi_id = '"+busiId+"' and t.dp_status = 1";
		whereSqlExt.setWhereSql(whereSql);
		List<Map<String, String>>  cwIncomeExpensesItem = publicDao.selectWhereSql(whereSqlExt);
		maps.put("cwIncomeExpensesItem", cwIncomeExpensesItem);
		
		//逾期表数据
		whereSql = "select t.id,t.amount_remainder from dh_overduelist t where t.busi_id = '"+busiId+"'";
		whereSqlExt.setWhereSql(whereSql);
		List<Map<String, String>>  dhoverdueList = publicDao.selectWhereSql(whereSqlExt);
		maps.put("dhoverdueList", dhoverdueList);
		
		//结算方式
		Map<String, String> settlement_type = iCachedDictionaryService.getValueNamesWithSpaceOption(DataDicType.SETTLEMENT_TYPE,"请选择...");
		maps.put("settlement_type", settlement_type);
		
		return maps;
    }
	
}
